from functools import partial
import pymysql
import os

DB_HOST = os.getenv('DB_HOST') or 'localhost'
DB_PORT = int(os.getenv('DB_PORT') or '3306')
DB_USER = os.getenv('DB_USER') or 'guest'
DB_PASS = os.getenv('DB_PASS') or 'Guset.618'
DB_NAME = os.getenv('DB_NAME') or 'data_viz'
DB_CHAR = os.getenv('DB_CHAR') or 'utf8mb4'

db_config = {
    'host': DB_HOST,
    'port': DB_PORT,
    'user': DB_USER,
    'password': DB_PASS,
    'database': DB_NAME,
    'charset': DB_CHAR
}
connect_mysql = partial(pymysql.connect, **db_config)

def get_mysql_connection(database=DB_NAME):
    return connect_mysql(database=database)
  


